package com.itheima.mapper;

import com.itheima.jopo.Emp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * EmpMapper
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/4/29 16:15
 */
@Mapper
public interface EmpMapper {
    /**
     * 查询总数量
     *
     * @return
     */
    @Select("select count(*) from emp")
    Long selectCount();

    /**
     * @return
     */
    List<Emp> selectList(String name, Integer gender, LocalDate begin, LocalDate end);

    /**
     * 批量删除
     *
     * @param ids
     */
    void deleteByIds(List<Integer> ids);

    @Insert("insert into emp(username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
            "values (#{username}, #{password}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})")
    void insertOne(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    void update(Emp emp);
}
